﻿namespace fangchengzu
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请输入a的值:");
            int a = int.Parse(Console.ReadLine());
            Console.WriteLine("请输入b的值:");
            int b = int.Parse(Console.ReadLine());
            Console.WriteLine("请输入c的值:");
            int c = int.Parse(Console.ReadLine());

            double x1, x2;
            if(b*b-4*a*c>0)
            {
                x1 = (-b + Math.Sqrt(b * b - 4 * a * c)) / 2 * a;
                x2 = (-b - Math.Sqrt(b * b - 4 * a * c)) / 2 * a;
                Console.WriteLine("一元二次方程{0}*x*x+{1}*x+{2}=0的根为：{3}\t{4}", a, b, c, x1, x2);
            }
            else if(b*b-4*a*c==0)
            {
                x1 = (-b + Math.Sqrt(b * b - 4 * a * c)) / 2 * a;
                Console.WriteLine("一元二次方程{0}*x*x+{1}*x+{2}=0的根为：{3}", a, b, c, x1);
            }
            else
            {
                Console.WriteLine("一元二次方程{0}*x*x+{1}*x+{2}=0无解！", a, b, c);
            }
        }
    }
}